$NG.AllReady(function (page, { useValuesChange,useDataIndexChange,useUpdateRows,useUpdateRow }) {
    const mstform = $NG.getCmpApi("p_form_track_insert_m")
    const dgrid1 = $NG.getCmpApi("p_form_track_insert_d")  
    useDataIndexChange(({args})=>{//
        const data = args[0]
        getPtInfoByPhid(data.phid_pc,(datas)=>{
            data.u_devision=datas.division_phid
            data.u_devision_EXName=datas.division_name

            data.u_regional_center = datas.regional_center_phid
            data.u_regional_center_EXName = datas.regional_center_name

            data.u_cpx = datas.midwife_phid
            data.u_cpx_EXName = datas.midwife_name

            data.phid_customer_ent = datas.customer_id
            data.phid_customer_ent_EXName = datas.customer_name
            dgrid1.refreshView()
        })
    },"phid_pc")
    useValuesChange(({args})=>{
      const phid = mstform.getItem("creator").getValue()
      console.log(phid);
      getBasiceTable()
    },"p_form_track_insert_m.creator")
    getBasiceTable()
    function getBasiceTable(){
      const phid = mstform.getItem("creator").getValue()
      if(!phid) return
      $NG.execServer("getBasiceTable",{phid},(res)=>{
        console.log(res);
        if(res.count==0) return 
        const _data = JSON.parse(res.data)
        console.log(`回款负责人带出数据`,_data);
        const _temp = []
        _data.forEach(items => {
          const item = items.extendObjects
          _temp.push({
            phid_pc:item.phid_pc,
            phid_pc_EXName:item.phid_name,
            u_devision:item.devision,
            u_devision_EXName:item.devision_exname,
            u_regional_center:item.qyzx,
            u_regional_center_EXName:item.qyzx_name,
            u_cpx:item.cpx,
            u_cpx_EXName : item.cpx_exname,
            u_hklx:item.hklx
          })
          dgrid1.clearRows().then(()=>{
            dgrid1.addRows(_temp)
          })
        });
      })
    }
    // 获取项目信息
    function getPtInfoByPhid(phid,fun) {
        if (phid) {
          $NG.execServer("getPtInfoByPhid", { phid }, function (res) {
            const datas = JSON.parse(res.data)[0].extendObjects;
            console.log(datas);
            fun(datas)
            // $NG.updateState((updater) => {
            //   updater.data.当前表名.setProps({
            //     //项目编码
            //     pc_no: datas.pc_no,
            //     //项目金额
            //     approx_contract_fc: datas.approx_contract_fc,
            //     //计划开工日期
            //     start_date: datas.start_date,
            //     //计划完工日期
            //     end_date: datas.end_date,
            //     //售前顾问
            //     u_sqgw: { value: datas.user_sqgw_phid, label: datas.user_sqgw_name },
            //     //项目经理
            //     u_project_manager: { value: datas.project_manager_phid, label: datas.project_manager_name },
            //     //事业部
            //     u_division: { value: datas.division_phid, label: datas.division_name },
            //     //组织
            //     phid_org_phid: { value: datas.phid_org_phid, label: datas.phid_org_name },
            //     //区域中心
            //     u_regional_center: { value: datas.regional_center_phid, label: datas.regional_center_name },
            //     //产品线
            //     user_product_line: { value: datas.midwife_phid, label: datas.midwife_name },
            //     //客户名称
            //     customer: { value: datas.customer_id, label: datas.customer_name },
            //     //部门
            //     u_dept: { value: datas.dept_phid, label: datas.dept_name },
            //     //项目类型
            //     u_pc_type: { value: datas.type_phid, label: datas.type_name },
            //     //项目预算组织编码
            //     budget_org_code: datas.budget_org_no,
            //     //项目预算组织
            //     budget_org_phid: { value: datas.budget_org_phid, label: datas.budget_org_name },
            //   });
            // });
          });
        }
      }
      
})